package com.share.wechat.order.common.constant;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * 支付方式记录集合
 */
public class PayWayConstant {
    /**
     * 支付宝
     */
    public static final int PAY_BY_ALI_PAY = 1;
    /**
     * 微信
     */
    public static final int PAY_BY_WE_CHAT = 1;
    public static final int PAY_BY_OTHER_PAY = 99;
    /**
     * 支付宝中文编码
     */
    public static final String ALI_PAY_CHINESE = "支付宝";
    /**
     * 微信中文编码
     */
    public static final String WE_CHAT_CHINESE = "微信";
    public static final String OTHER_PAY_CHINESE = "微信";

    public static final Map<Integer, String> payMap = new HashMap<>();

    static {
        payMap.put(PayWayConstant.PAY_BY_ALI_PAY, PayWayConstant.ALI_PAY_CHINESE);
        payMap.put(PayWayConstant.PAY_BY_WE_CHAT, PayWayConstant.WE_CHAT_CHINESE);
        payMap.put(PayWayConstant.PAY_BY_OTHER_PAY, PayWayConstant.OTHER_PAY_CHINESE);
    }

    /**
     * 根据编码拿到支付方式
     * @param code 编码
     * @return 支付方式
     */
    public static String getPayWordByCode(int code) {
        return payMap.get(code);
    }

    /**
     * 根据中文编码拿到支付编码
     * @param word 中文支付中文
     * @return 支付编码
     */
    public static int getPayCodeByWord(String word) {
        Set<Integer> keySet = payMap.keySet();
        for (Integer key : keySet) {
            if (payMap.get(key).equals(word)) {
                return key;
            }

        }
        return -1;
    }


}
